package com.jbit.dm212.controller;

import com.alipay.api.AlipayApiException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.jbit.dm212.common.DmAlipayUtil;
import com.jbit.dm212.common.ResponseResult;
import com.jbit.dm212.common.ResponseResultUtils;
import com.jbit.dm212.entity.alipay.AliOrderPay;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/pay/api/v")
public class AlipayVerifyController {
    @PostMapping("/alipay")
    public ResponseResult payPc(@RequestBody AliOrderPay aliOrder){
        try {
            String result = DmAlipayUtil.payPC(aliOrder);

            System.out.println(result);
            return ResponseResultUtils.sendSuccess(result);
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        } catch (AlipayApiException e) {
            e.printStackTrace();
        }
        return ResponseResultUtils.sendError("0001");
    }

    @RequestMapping("/p")
    public ResponseResult tradeSuccess(){
        return null;
    }

}
